<script>
  import CollapseTransition from './collapse-transition'
  import index from "../index";
  function createNode(createElement, data) {
    return data ? data.map((dataNode) => {
      if (this.filter && !this.filter(dataNode)) {
        return undefined
      }
      let subNode = createNode(createElement, dataNode.children)
      //if(dataNode.expanded==undefined||dataNode.expanded==true){
        return createElement('tree-node', {
          props: {data: dataNode,parent:data},
          scopedSlots: {
            content: this.$scopedSlots.default
          },
          create(){
          }
        }, subNode)
     // }
    }) : undefined
  }

  export default {
    data(){
      return {
        parent: String
      }
    },
    name: 'GTree',
    components:{CollapseTransition},
    render: function (createElement) {
      return createElement('collapse-transition',{},[createElement('div', createNode(createElement, this.data))])
    },
    props: {
      data: Array,
      filter: Function,
    },
    methods: {
    },
    created() {
      createNode = createNode.bind(this);
      console.log(this,'this');
    }
  }
</script>
